Suppress zero byte writes for benefit of Bob Anderson's Keyspan USB/Serial adapter.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 16 Nov 2004 03:50:19 +0000 (03:50 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 16 Nov 2004 03:50:19 +0000 (03:50 +0000)
gpsbabel/jeeps/gpsserial.c

index b2a51bb22c46704437b0c452f21b1b639abb7429..f7d5d631a7fc87ff667ff9af6154280a3981f170 100644 (file)
@@ -180,6 +180,17 @@ int32 GPS_Serial_Flush(int32 fd)
 int32 GPS_Serial_Write(int32 ignored, const void *obuf, int size)
 {
        DWORD len;
+
+       /* 
+        * Unbelievably, the Keyspan PDA serial driver 3.2, a "Windows 
+        * Certified driver", will crash the OS on a write of zero bytes.
+        * We get such writes from upstream when there are zero payload
+        * bytes.  SO we trap those here to stop Keyspan & Windows from
+        * nuking the system.
+        */
+       if (size == 0) {
+               return 0;
+       }
        WriteFile (comport, obuf, size, &len, NULL);
        if (len != size) {
                fatal ("Write error.   Wrote %d of %d bytes.", len, size);